var registerInp = document.getElementById('formInput').getElementsByTagName('input');
var errorText = document.getElementsByClassName('error_text');
//判断字符串长度
/**
 * @param str 要检测的字符串
 * @param Length  必须的长度
 * @returns {*}
 */
function checkLength(str,Length){
     if (str.length<Length){
             return false;
     }else{
             return true;
     }
}

function showerror(obj,text){
    obj.innerHTML = text;
    Move(obj,'left',0);
}

function clerarerror(obj){
    obj.style.left = 100+'%';
}

function creatLayout(Html){
     var Layout = document.createElement('div');
     Layout.className = 'code_tips';
     Layout.innerHTML = Html;
     document.body.appendChild(Layout);
     Move(Layout,'opacity',100);
     setTimeout(function(){
           Move(Layout,'opacity',0);
           setTimeout(function(){
                 document.body.removeChild(Layout);
           },500)
     },1000)
}

registerInp[0].onblur = function(){

      if (this.value == ''){
          showerror(errorText[0],'昵称不能为空！');
          return;
      }
      if(!checkLength(this.value,5)){
          showerror(errorText[0],'昵称至少输入3位！');
          return;
      }
      clerarerror(errorText[0]);
}


registerInp[1].onblur = function(){

    if (this.value == ''){
        showerror(errorText[1],'账号不能为空！');
        return;
    }
    if(!checkLength(this.value,5)){
        showerror(errorText[1],'账号至少输入6位！');
        return;
    }
    clerarerror(errorText[1]);
}


registerInp[2].onblur = function(){

    if (this.value == ''){
        showerror(errorText[2],'密码不能为空！');
        return;
    }
    if(!checkLength(this.value,5)){
        showerror(errorText[2],'密码至少输入6位！');
        return;
    }
    clerarerror(errorText[2]);
}

registerInp[3].onblur = function(){

    if (this.value == ''){
        showerror(errorText[3],'确认密码不能为空！');
        return;
    }

    if (this.value != registerInp[2].value){
        showerror(errorText[3],'两次输入的密码不一致！');
        return;
    }
    clerarerror(errorText[3]);
}

function checkFrom(){
      for(var i=0;i<registerInp.length;i++){
           if (registerInp[i].value == ''){
                 creatLayout('请填写完整注册信息');
                 return false;
           }
      }
}